﻿using System.ComponentModel.DataAnnotations;
using WebConversion.Module;

namespace WebConversion.Mvc.Models
{
    public class RecommendationModel
    {
        [Display(Name = "1st recommendation")]
        public DailyRecommendation FirstRecommendation { get; set; }

        [Display(Name = "2nd recommendation")]
        public DailyRecommendation SecondRecommendation { get; set; }

        [Display(Name = "3rd recommendation")]
        public DailyRecommendation ThirdRecommendation { get; set; }

        public static RecommendationModel FillInRecommendation()
        {
            var recommendations = Repository.List<DailyRecommendation>();
            if (recommendations == null
                || recommendations.Count == 0)
            {
                return null;
            }

            var recommendationModel =
                new RecommendationModel()
                    {
                        FirstRecommendation = recommendations.Count >= 1 ? recommendations[0] : null,
                        SecondRecommendation = recommendations.Count >= 2 ? recommendations[1] : null,
                        ThirdRecommendation = recommendations.Count >= 3 ? recommendations[2] : null,
                    };

            return recommendationModel;
        }
    }
}